// DCStatusDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DeviceCloud.h"
#include "DCAccountDlg.h"


// CDCAccountDlg dialog

CDCAccountDlg::CDCAccountDlg(CWnd* pParent /*=NULL*/)
	: CDialogChildBase(CDCAccountDlg::IDD, IDB_DLGC_BG, pParent)
{

}

CDCAccountDlg::~CDCAccountDlg()
{
}

void CDCAccountDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogChildBase::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_STC_ASTATUS, m_stcStatus);
	DDX_Control(pDX, IDC_STC_GMAIL, m_stcGmail);
	DDX_Control(pDX, IDC_STC_PASS, m_stcPass);
	DDX_Control(pDX, IDC_EDT_GMAIL, m_edtGmail);
	DDX_Control(pDX, IDC_EDT_PASS, m_edtPass);
	DDX_Control(pDX, IDC_BTN_SIGNIN, m_btnSignin);
}

bool CDCAccountDlg::OnInitChildControls()
{
	m_stcStatus.SetFontFamily(_T("Arial"));      m_stcStatus.SetFontSize(11);
	m_stcStatus.SetFontStyle(1);                 m_stcStatus.SetFontColor(255, 255, 255);

	m_stcGmail.SetFontFamily(_T("Arial"));    m_stcGmail.SetFontSize(8);
	m_stcGmail.SetFontStyle(1);               m_stcGmail.SetFontColor(255, 255, 255);

	m_stcPass.SetFontFamily(_T("Arial"));    m_stcPass.SetFontSize(8);
	m_stcPass.SetFontStyle(1);               m_stcPass.SetFontColor(255, 255, 255);

	RECT rect;	
	GetClientRect(&rect);
	ClientToScreen(&rect);

	m_btnSignin.SetBntPicsID(IDB_BTNN_HO, IDB_BTNN_DE, IDB_BTNN_PR, IDB_BTNN_DI);
	return true;
}

BEGIN_MESSAGE_MAP(CDCAccountDlg, CDialogChildBase)
	ON_BN_CLICKED(IDC_BTN_SIGNIN, &CDCAccountDlg::OnBnClickedBtnSignin)
END_MESSAGE_MAP()

// CDCStatusDlg message handlers
BOOL CDCAccountDlg::OnInitDialog()
{
	CDialogChildBase::OnInitDialog();
	return TRUE;  // return TRUE  unless you set the focus to a control
}
static int a = 0;

void CDCAccountDlg::OnBnClickedBtnSignin()
{
	// TODO: Add your control notification handler code here
	if(a++ % 2 == 0) {
		lscb ls_cb = (lscb)&CDCAccountDlg::OnLoginStatusCallback;
		rscb rs_cb = (rscb)&CDCAccountDlg::OnRosterStatusCallback;
		cscb cs_cb = (cscb)&CDCAccountDlg::OnCallStatusCallback;

		core.SetCoreCallBack(ls_cb, rs_cb, cs_cb);
		core.Login("dvmqa20@gmail.com", "devicevm", "dvm", "");
	}
	else {
		core.MakeCall("dvmqa20@gmail.com/strwin:0001:uuid=c3e311cbf5f82d41a6e01a9d9f345c73");
		//core.Logout();
	}
}

void CDCAccountDlg::OnLoginStatusCallback(const struct status_msg msg)
{
	printf("***************The Login Status Call back (%d, %d, %s).\n", msg.status, msg.error, msg.error);
}

void CDCAccountDlg::OnRosterStatusCallback(const char* jid, int sid, const char* pcname, const char* status)
{
	printf("***************The Roster Status Call back (%s, %d, %s, %s).\n", jid, sid, pcname, status);
}

void CDCAccountDlg::OnCallStatusCallback(const char* jid, int state)
{
	printf("***************The Call Status Call back (%s, %d).\n", jid, state);
}

